package com.loan.repository;

import com.loan.entity.CategoryChannel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * Created by huxudong on 17/6/29.
 */
public interface CategoryChannelRepository extends JpaRepository<CategoryChannel,Long>     {

    @Query("select a from CategoryChannel a where a.category.id = :categoryId")
    List<CategoryChannel> findByCategory(@Param("categoryId") Long categoryId);

    @Modifying
    @Transactional
    @Query("DELETE CategoryChannel c where c.id = ?2")
    public void deleteById(Integer isHot , Long id);

    @Modifying
    @Transactional
    @Query("DELETE CategoryChannel c where c.channel.id = ?1")
    public void deleteByChannelId(Long channnelId);

}

